package com.prp.gwt.client.widgets.admin;

import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.prp.gwt.client.admin.AdminHistoryHandler;
import com.prp.gwt.client.widgets.MessageDialogBox;

public class AccountManagement extends VerticalPanel{

	private static AccountManagement instance;
	private DeckPanel deckPanel = new DeckPanel();
	public static final int QUERY_PANEL	 = 0;
	public static final int INACTIVATED_USER_PANEL = 1;
	protected HTML email = new HTML();
	
	public static AccountManagement getInstance(){
		if(instance == null)
			instance = new AccountManagement();
		return instance;
	}
	
	private AccountManagement(){
		add(getTabBar());
		deckPanel.add(UserQueryPanel.getInstance());
		deckPanel.add(InactivatedUserList.getInstance());
		deckPanel.showWidget(QUERY_PANEL);
		add(deckPanel);
	}
	
	public void showWidget(int index){
		deckPanel.showWidget(index);
	}
	
	private HorizontalPanel getTabBar(){
		HorizontalPanel panel = new HorizontalPanel();
		panel.setSpacing(5);
		Hyperlink query = new Hyperlink("查找用户", AdminHistoryHandler.USERQUERY);
		Hyperlink activate = new Hyperlink("激活用户", AdminHistoryHandler.ACTIVATEUSER);
		panel.add(query);
		panel.add(activate);
		return panel;
	}
	
	public void showRegisterSuccess(String email){
		String html = "帐户"+email+"注册成功";
		html += "<br/>但该帐户尚未激活";
		MessageDialogBox.show("注册成功", html);
	}
	
}
